<?php $this->pageHeader('Arrangementdetaljer'); ?>
 <p id="top_right_links">
<?php if($this->isAdmin) : ?>
<a href="<?php echo $this->url(array('module' => 'admin', 'controller' => 'event', 'action' => 'edit', 'id' => $this->eventId)); ?>" class="button"><img src="<?php echo $this->imageLink('images/icons/pencil.png'); ?>" />Rediger</a>
<a href="<?php echo $this->url(array('action' => 'delete', 'controller' => 'event', 'module' => 'admin', 'id' => $this->eventId)); ?>" class="button negative"><img src="<?php echo $this->imageLink('images/icons/delete.png'); ?>" />Slett</a>
<?php endif; ?>
<?php
$eventDate = new RedCross_Date($this->event->to_date);
$nowDate = new RedCross_Date();
$isFutureEvent = $eventDate->isLater($nowDate);
$eventType = $this->event->type;
$shiftEvent = "Vaktarrangement";
if ($isFutureEvent && ($eventType == $shiftEvent)) :
    if ($this->hasInterest == null):
        $icon = $this->imageLink('images/icons/accept.png');
        $class = 'positive';
        $text = 'Vis interesse';
    else:
        $icon = $this->imageLink('images/icons/cancel.png');
        $class = 'negative';
        $text = 'Fjern interesse';
    endif;
?>
    <a href="<?php echo $this->url(array('module' => 'core', 'controller' => 'event', 'action' => 'toggleinterest', 'id' => $this->eventId), null, true); ?>" class="button <?php echo $class; ?>">
        <img src="<?php echo $icon; ?>" />
        <?php echo $text; ?>
    </a>
<?php endif; ?>
</p>
<?php echo $this->flashMessage()->renderMessages(); ?>

<?php
  if (isset($this->flash))
  {
    foreach ($this->flash as $flash)
      echo $flash;
  }
?>

<h1>Detaljer for "<?php echo $this->escape($this->event->name); ?>"</h1>

<?php echo $this->render('event/_event.phtml'); ?>

<p>&nbsp;</p>
<?php if($eventType == $shiftEvent): ?>
<h2>Vakter</h2>

<table class="core_event">
    <thead>
        <tr>
            <th>Navn</th>
            <th>Oppmøte depot</th>
            <th>Oppmøte arr</th>
            <th>Antatt ferdig</th>
            <th>&nbsp;</th>
        </tr>
    </thead>
    <tbody>
        <?php foreach($this->shifts as $shift) : ?>
          <?php
                $appearanceTime = new RedCross_Date();
                $appearanceTime->import($shift['appearance_time']);
                
                $fromDate = new RedCross_Date();
                $fromDate->import($shift['from_date']);
                
                $toDate = new RedCross_Date();
                $toDate->import($shift['to_date']);
            ?>
            <tr>
                <td>
                    <a href="<?php echo $this->url(array('module' => 'core', 'controller' => 'shift', 'action' => 'view', 'id' => $shift['id']), null, true); ?>"><?php echo $this->escape($shift['name']); ?></a>
                </td>
                <td><?php if ($appearanceTime == $fromDate) { echo "Direkte på arr"; } else { echo $appearanceTime->getDateTimeStr(); } ?></td>
                <td><?php echo $fromDate->getDateTimeStr(); ?></td>
                <td><?php echo $toDate->getDateTimeStr(); ?></td>
                <td>
                    <a href="<?php echo $this->url(array('module' => 'core', 'controller' => 'shift', 'action' => 'view', 'id' => $shift['id']), null, true); ?>"><img src="<?php echo $this->imageLink('images/icons/shift_go.png'); ?>" alt="Vis vakt" title="Vis" /></a>
                <?php if($this->isAdmin) : ?>
                    <a href="<?php echo $this->url(array('module' => 'admin', 'controller' => 'shift', 'action' => 'edit', 'id' => $shift['id']), null, true); ?>"><img src="<?php echo $this->imageLink('images/icons/shift_edit.png'); ?>" alt="Rediger Vakt" title="Rediger" /></a>
                <?php endif; ?>
                </td>
            </tr>
        <?php
            endforeach;
        ?>
    </tbody>
</table>
<?php endif; ?>
<?php
if($this->canCreateShift && $eventType == $shiftEvent) : ?>
    <a href="<?php echo $this->url(array('module' => 'admin', 'controller' => 'shift', 'action' => 'create', 'event' => $this->eventId), null, true); ?>" class="button"><img src="<?php echo $this->imageLink('images/icons/add.png'); ?>" />Opprett ny vakt</a>
<?php endif; ?>
